import fs from "fs";
import { fileURLToPath } from "url";
import { dirname } from "path";
import Router from "koa-router";
const router = new Router();
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

fs.readdirSync(__dirname).forEach((file) => {
  if (file.endsWith(".js") && file !== "index.js") {
    // koa 自动导入模块
    import(`./${file}`).then((module) => {
      router.use(module.default.routes());
    });
  }
});
export default router;
